package com.newasia.server.common.result;

public enum ManagementRetCode {

    // 系统公用
    SUCCESS                             ("000000", "成功"),
    UNKNOW_ERROR                        ("000001", "未知错误"),
    NOT_LOG_IN                          ("000002", "未登录"),
    REQUISITE_PARAMETER_NOT_EXIST     ("001001", "必要的参数不能为空"),
    REQUISITE_PARAMETER_ERROR          ("001002", "必要的参数错误"),

    //用户部分
    USERORPASSWORD_ERRROR                   ("002001","用户名或密码不正确"),
    TOKEN_VALID_FAILED                      ("002002","token校验失败"),
    USERNAME_ALREADY_EXISTS                 ("002003","用户名已存在"),
    USER_REGISTER_FAILED                    ("002004","注册失败，请联系管理员"),
    KAPTCHA_CODE_ERROR                      ("002005","验证码不正确"),
    USER_FROZEN                             ("002006","用户被冻结"),
    USERNAME_NOT_EXIST                      ("002007","用户名不存在"),
    WECHAT_UNBOUND                           ("002008","微信未绑定账户"),
    MOBILE_ERROR                            ("002009","电话号码格式有误"),
    ILLEGAL_USERNAME                          ("002010","用户名不符合规范"),
    ILLEGAL_PASSWORD                            ("002011","密码不符合规范"),
    PASSWORD_TOO_LONG                           ("002012","密码过长"),
    PASSWORD_TOO_SHORT                         ("002013","密码过短"),
    USERORPASSWORD_NOT_EXIST                   ("002014","用户名或密码不能为空"),
    KAPTCHA_NOT_EXIST                          ("002015","验证码不能为空"),
    KAPTCHA_OVER_TIME                           ("002016","验证码超时"),
    MOBILE_NOT_MATCH                          ("002017","电话号码不匹配"),
    KAPTCHA_IS_USED                           ("002018","验证码已被使用"),
    PASSWORD_INCONFORMITY                     ("002019","两次密码不相符"),
    PASSWORD_ERROR                              ("002020","输入密码不正确"),

    REQUEST_FORMAT_ILLEGAL              ("009060", "请求数据格式非法"),
    REQUEST_IP_ILLEGAL                  ("009061", "请求IP非法"),
    REQUEST_CHECK_FAILURE               ("009062", "请求数据校验失败"),
    DATA_NOT_EXIST                      ("009070", "数据不存在"),
    DATA_REPEATED                       ("009071", "数据重复"),
    REQUEST_DATA_NOT_EXIST              ("009072", "传入对象不能为空"),
    REQUEST_DATA_ERROR                  ("009074", "必要的参数不正确"),
    PERMISSION_DENIED                   ("009091", "权限不足"),
    REQUEST_CHARACTERS_ILLEGAL          ("009092", "请求数据有非法字符"),

    DB_EXCEPTION                        ("109097", "数据库异常"),
    SYSTEM_TIMEOUT                      ("109098", "系统超时"),
    SYSTEM_ERROR                        ("109099", "系统错误");



    private String code;
    private String message;

    ManagementRetCode(String code, String message) {
        this.code = code;
        this.message = message;
    }

    /**
     * Getter method for property <tt>code</tt>.
     *
     * @return property value of code
     */
    public String getCode() {
        return code;
    }

    /**
     * Setter method for property <tt>code</tt>.
     *
     * @param code value to be assigned to property code
     */
    public void setCode(String code) {
        this.code = code;
    }

    /**
     * Getter method for property <tt>message</tt>.
     *
     * @return property value of message
     */
    public String getMessage() {
        return message;
    }

    /**
     * Setter method for property <tt>message</tt>.
     *
     * @param message value to be assigned to property message
     */
    public void setMessage(String message) {
        this.message = message;
    }

    public static String getMessage(String code) {
        for (ManagementRetCode s : ManagementRetCode.values()) {
            if (null == code)
                break;
            if (s.code.equals(code)) {
                return s.message;
            }
        }
        return null;
    }
}
